<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>短信发送管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/docheck/docheck.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function showTestModal(smsContent){
			$('#smsContent').val(smsContent);
			$('#smsContentSize').text(smsContent.length);
			$('#smsContentModal').modal('show');
		}
        //通知 0 设置成功 1设置失败
        function checkSendStatus(type,sendStatus){
            var ids = getCheckboxValue("id");
            if(!ids){
                alert("请选择要处理的记录");
            }else {
                setSendStatus(ids, type, sendStatus);
            }
        }
        //通知 0 设置成功 1设置失败
        function setSendStatus(id, type,sendStatus){
            var actionUrl = "${ctx}/sms/smsSend/setSendStatus?ids=" + id + "&type=" + type + "&sendStatus=" + sendStatus;
            var status = "审核成功"
			if (status =="F001") {
                status = "审核失败"
			}
            top.$.jBox.confirm("确认设置状态为"+status+"吗？选择是，修改状态，选择否，取消修改","系统提示",function(v,h,f) {
                if (v == "ok") {
                    $.ajax({
                        url: actionUrl,
                        success: function (data) {
                            alert(data);
                            page();
                        },
                        error: function () {
                            alert("设置失败");
                        },
                        dataType: "text"
                    });
                }
            },{buttonsFocus:1});
            top.$('.jbox-body .jbox-icon').css('top','55px');
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sms/smsSend/">信息列表</a></li>
		<!--<shiro:hasPermission name="sms:smsSend:edit"><li><a href="${ctx}/sms/smsSend/form">短信发送添加</a></li></shiro:hasPermission>-->
	</ul>
	<form:form id="searchForm" modelAttribute="smsSend" action="${ctx}/sms/smsSend/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>短信ID：</label>
				<form:input path="id" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>用户ID：</label>
				<form:input path="userid" htmlEscape="false" maxlength="11" class="input-medium"/>
			</li>
			<li><label>批次ID：</label>
				<form:input path="taskid" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>手机号码：</label>
				<form:input path="phoneFind" htmlEscape="false" maxlength="32" class="input-medium"/>
			</li>
			<li><label>运营商：</label>
				<form:select path="phoneType" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getDictList('phone_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>

			<li><label>是否失效：</label>
				<form:select path="isEffective" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getDictList('isEffective')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>是否批量：</label>
				<form:select path="showLevel" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getDictList('showLevel')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>

			<li><label>网关编号：</label>
				<form:input path="gatewayId" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<!-- <li><label>网关状态：</label>
				<form:input path="gatewayStatus" htmlEscape="false" maxlength="20" class="input-medium"/>
			</li> -->
			<li><label>发送时间：</label>
				<input name="sendTimeQ" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${smsSend.sendTimeQ}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> -
				<input name="sendTimeZ" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${smsSend.sendTimeZ}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
		</ul>
		<ul class="ul-form">
			<%--<li class="btns"><input id="checkSuccSubmit" class="btn btn-primary" type="submit" value="审核通过" onclick="javasrcipt:checkSendStatus(1,'TOOO');" /></li>--%>
			<%--<li class="btns"><input id="checkFailSubmit" class="btn btn-primary" type="submit" value="审核不通过" onclick="javasrcipt:checkSendStatus(1,'FOO1');" /></li>--%>
			<!--
			<li class="btns"><input id="sendSuccSubmit" class="btn btn-primary" type="submit" value="发送成功" onclick="javasrcipt:checkSendStatus(1,'TOOO');" /></li>
			<li class="btns"><input id="sendFailSubmit" class="btn btn-primary" type="submit" value="发送失败" onclick="javasrcipt:checkSendStatus(1,'FOO1');" /></li>
			<li class="btns"><input id="againSubmit" class="btn btn-primary" type="submit" value="重新提交网关" onclick="javasrcipt:checkSendStatus(1,'FOO1');" /></li>
			-->
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" onclick="doCheckAll(this,'id', this.checked)"></th>
				<th>提交人</th>
				<th>提单号</th>
				<th>手机号码</th>
				<th>发送时间　　</th>
				<th>定时时间</th>
				<th>短信内容</th>
				<th>计数</th>
				<th>运营商</th>
				<th>省份</th>
				<th>发送号码</th>
				<th>发送状态</th>
				<th>网关编号</th>
				<th>回执状态</th>
				<th>提交时间　　</th>
				<th>回执时间　　</th>
				<th>审核人id</th>
				<th>审核时间</th>
				<th>是否失效</th>
				<th>失败原因</th>
				<th>审核原因</th>
				<th>待发原因</th>

				<!-- <th>发送时间　　　　　　</th> -->
				<!-- <th>推送状态</th>
				<th>短信ID</th>
				<th>批次ID</th>
				 -->
				<shiro:hasPermission name="sms:smsSend:edit"><th>操作</th></shiro:hasPermission>

			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="smsSend">
			<tr onclick="selectTr(this, '${smsSend.id}' ,'id')">
				<td><input type="checkbox" name="id" id="${smsSend.id}" value="${smsSend.id}" onclick="if(this.checked){this.checked=false;}else{this.checked=true;}"></td>
				<td>
						${fns:getUser().loginName}
						<c:if test="${smsSend.smsType eq '1'}">
							|行业用户
						</c:if>
							<c:if test="${smsSend.smsType eq '2'}">
								|验证码用户
							</c:if>
					<c:if test="${smsSend.smsType eq '3'}">
						|营销用户
					</c:if>
							<c:if test="${smsSend.smsType eq '4'}">
								|群发用户
							</c:if>
				</td>
				<td>
						${smsSend.id}
				</td>
				<td>${fn:substring(smsSend.phone, 0, 20)}...
					<a href="javascript:showTestModal('${fns:escapeHtml(smsSend.phone)}')">[更多查看]</a>
				</td>
				<td>
					<fmt:formatDate value="${smsSend.sendTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${smsSend.autosendTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${fn:substring(smsSend.smsContent, 0, 20)}...
					<a href="javascript:showTestModal('${fns:escapeHtml(smsSend.smsContent)}')">[更多查看]</a>
				</td>
				<td>
					${smsSend.smsSize}
				</td>
				<td>
					${fns:getDictLabel(smsSend.phoneType, 'phone_type', '')}
				</td>

				<td>
					${fns:getDictLabel(fn:substring(smsSend.phoneArea,0,2),'phone_province',smsSend.phoneArea)}	
				</td>
				<td>
					${smsSend.spnumber}
				</td>
				<td>
					${fns:getDictLabel(smsSend.sendStatus, 'sendStatus', '')}
					<%--${fns:startsWith(smsSend.sendStatus,'T') ? '发送成功' : '发送失败'}--%>
				</td>
				<td>
					${smsSend.gatewayId}
				</td>
				<td>
					${smsSend.gatewayStatus eq 'T100' ? 'DELIVRD' : smsSend.gatewayStatus}
				</td>
				<td>
					<fmt:formatDate value="${smsSend.receiveTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>				
				 <td>
					<fmt:formatDate value="${smsSend.reportTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
					${smsSend.checkUserid}
				<td>

				</td>
				<td>
					<fmt:formatDate value="${smsSend.checkTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
						${fns:getDictLabel(smsSend.isEffective, 'isEffective', '')}
				</td>
				<td>${smsSend.failReason}</td>
				<td>${smsSend.checkReason}</td>
				<td>${smsSend.waitReason}</td>




				<!-- <td>
					<fmt:formatDate value="${smsSend.sendTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td> -->
				<!-- 
				<td>
					${smsSend.userNotifyStatus eq 1 ? '成功' : smsSend.userNotifyStatus eq 0 ? '无' : smsSend.userNotifyStatus eq 2  ? '失败' : '待推'}
				</td>

				<td>
					${smsSend.id}
				</td>
				<td>
					${smsSend.taskid}
				</td>
				 -->
				<shiro:hasPermission name="sms:smsSend:edit"><td>
					<c:if test="${smsSend.sendStatus eq 'V000'}">
					<a href="javascript:setSendStatus('${smsSend.id}',1,'T000')">审核通过</a>
					<a href="javascript:setSendStatus('${smsSend.id}',1,'F001')">审核失败</a>
					</c:if>
					<%--<a href="javascript:windowOpen('${debug}/cache.jsp?type=1&key=${smsGateway.gwCode}','网关信息',900,550);">调试</a>--%>
					<!-- <a href="${ctx}/sms/smsGateway/delete?id=${smsGateway.id}" onclick="return confirmx('确认要删除该通道信息吗？', this.href)">删除</a> -->
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<!-- 短信内容 -->
	<div class="modal fade" style="display:none;" id="smsContentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   		<div class="modal-dialog">
      		<div class="modal-content">
        		<div class="modal-header">
            		<button type="button" class="close" 
               			data-dismiss="modal" aria-hidden="true">
                  		&times;
            		</button>
		            <h4 class="modal-title" id="myModalLabel">
		              	短信内容
		            </h4>
         		</div>
         		<div class="modal-body">
         			<form id="gateWaySendForm" class="form-horizontal">
	                	<div class="control-group">
	                     	<div class="controls1">
	                         	<textarea style="width:498px;" readonly="readonly" name="smsContent" id="smsContent" rows="6" cols="8"></textarea>
	                         	共 <label name="smsContentSize" id="smsContentSize"></label>  个字。
	                     	</div>
	                 	</div>
                 	</form>
         		</div>
      		</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
	<!-- END -->
	
</body>
</html>